{extend name="base/main" /}
{block name="body"}
<link rel="stylesheet" href="/static/layui/css/layui.css">
<script src="/static/layui/layui.js"></script>
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>出售管理 /出售列表</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="search-area" id="toggle" style="margin-bottom: 15px;">
                        <form class="form-horizontal m-t" action="{:url('speical/gethouse')}" method="get">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">素材名称：</label>
                                <div class="col-sm-3">
                                    <input name="title" type="text" class="form-control" value="{:input('title')}" />
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-1">
                                    <button class="btn btn-primary btn-sm" type="submit">搜索</button>
                                    <a href="{:url('speical/index')}" class="btn btn-default btn-sm">撤销搜索</a>
                                </div>
                            </div>
                        </form>
                    </div>
                    <a href="javascript:void(0);" class="btn btn-sm btn-primary search-toggle"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</a>
                    <div class="example-wrap">
                        <div class="example">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th><input type="checkbox" class="i-checks check-all"></th>
                                    <th>编号</th>
                                    <th>素材标题</th>
                                    <th>封面</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="data" id="vo"}
                                <tr>
                                    <td><input type="checkbox" class="i-checks ids" name="id" value="{$vo.id}"/></td>
                                    <td>{$vo.id}</td>
                                    <td>{$vo.name}</td>
                                    <td><img src="{$vo.img}" alt="" width="200px" height="200px"></td>
                                    
                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                            <button id="xuan" class="btn btn-primary">选择</button>
                        </div>
                    </div>
                </div>
            </div>
            {$list->render()|raw}
        </div>
    </div>
</div>
<script>
layui.use(['upload', 'element', 'layer','laydate'], function(){
  var $ = layui.jquery
  ,upload = layui.upload
  ,element = layui.element
  ,layer = layui.layer
  ,laydate = layui.laydate;
   var index = parent.layer.getFrameIndex(window.name);
   $('#xuan').on('click',function(){
    var day=document.getElementsByName('id');
    var checkArr = [];
    for (k in day) {
            if (day[k].checked)
                checkArr.push(day[k].value);
    }
     var checkArr=checkArr;
    
        console.log( checkArr);
        $.ajax({
         url:'{:url('Special/lod')}'  ,
         type:"POST",
         dataType:"json",
         data:{'data':checkArr},
         success:function(res){
            console.log(res.data);
             var parentFrame = $(window.parent.document);
             
            var data=res.data;
            var id ='';
            var html = '<tr>'+
                      '<td>编号</td>'+
                      '<td>素材标题</td>'+
                      '<td>封面</td>'+
                      '<td>是否免费</td>'+
                      '<td>操作</td>';
            for( i in data){
               
                id += ","+data[i]["id"];
                html +=
                  '</tr>'+
                    '<tr>'+
                     '<th><span>'+data[i]["id"]+'</span></th>'+
                     '<th><span>'+data[i]["name"]+'</span></th>'+
                     '<th><span><img width="100px" hight="100px" src="'+data[i]["img"]+'"></span></th>'+
                     '<th><span>'+data[i]["material"]+'</span></th>'+
                     '<th><span>'+data[i]["status"]+'</span></th>'+
                  '</tr>';
              console.log(html);
              parentFrame.find('#material_list').html(html);
               parentFrame.find('#matter_id').val(id); 
              /*
             parentFrame.find('#su_material').append(""+data[i]["material"]+"");
             parentFrame.find('#su_id').append(""+data[i]["id"]+"");
             parentFrame.find('#su_name').append(""+data[i]["name"]+"");
             parentFrame.find('#su_img').append( "<img src='"+data[i]["img"]+"'>" );
             parentFrame.find('#su_status').append(""+data[i]["status"]+"");*/
            }parent.layer.close(index);
         }
        });
   });
  });
</script>
{/block}